#ifndef _MYSQL_MODULE_H
#define _MYSQL_MODULE_H

/* todo
 * create a msg queue, support a API to add cmd to the msg queue, and support a
 * callback to notify the SQL result.
 */ 

#include "mysql/mysql.h"

NDINT32 init_db(NDINT8 *host, NDUINT32 port, NDINT8 *dbname, NDINT8 *user, NDINT8 *pwd);
NDINT32 close_db();

MYSQL_RES *query(NDINT8 *sql, NDINT32 noret, NDUINT32 *effect);
void free_query(MYSQL_RES *res);

MYSQL_ROW fetch_row(MYSQL_RES *res);
NDUINT32 escape_string(NDINT8 *to, const NDINT8 *from, NDUINT32 length);

const NDINT8 *fetch_field(MYSQL_ROW row, MYSQL_RES *res, NDINT8 *name, NDINT32 *len);
#endif
